package codename.carrot.bomberman.network.server;

import codename.carrot.bomberman.network.ConnectionThread;
import codename.carrot.bomberman.network.MessageHandler;
import codename.carrot.bomberman.network.MessageHandler.MessageType;

/**
 * This is the representation of the client running on the server.
 * @author Group A4.
 *
 */
public class ServerClientConnectionThread extends ConnectionThread {

	/**
	 * Constructs the server-client.
	 * @param clientID The id of this client (usually 1).
	 * @param messageHandler The message handler.
	 */
	public ServerClientConnectionThread(int clientID, MessageHandler messageHandler) {
		super.clientID = clientID;
		super.messageHandler = messageHandler;
		super.connected = true;
	}
	
	@Override
	public boolean send(Object object) {
		super.messageHandler.obtainMessage(MessageType.RECEIVE, 0, object).sendToTarget();
		return true;
	}

	@Override
	public void terminate() {
		super.connected = false;
		interrupt();
	}

	@Override
	public void run() {}
	
	

}
